import * as actionTypes from "./constants";

const initialState = {
  counter: 1,
};

function reducer(state = initialState, action) {
  const { payload } = action;
  switch (action.type) {
    case actionTypes.ADD:
      return { ...state, counter: state.counter + payload };
    case actionTypes.MINUS:
      return { ...state, counter: state.counter - payload };
    default:
      return state;
  }
}

export default reducer;
